﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Topshelf;

namespace Quartz.NET.Practice
{
    /// <summary>
    /// 一套任务调度程序
    /// 使用Quartz.Net实现任务触发
    /// 使用TopShelf实现服务部署，运行与卸载
    /// 使用Log4Net实现日志记录
    /// 使用Dapper作为Light ORM
    /// </summary>
    class Program
    {

        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
            //服务运行代理
            HostFactory.Run((x)=>
            {
                x.Service<LogService>(s =>
                {
                    s.ConstructUsing(name => new LogService());
                    s.WhenStarted(tc => tc.OnStart());
                    s.WhenStopped(tc => tc.OnStop());
                });
                x.RunAsLocalSystem();
                x.SetDescription("测试Quartz、TopShelf、Log4Net与Dapper");
                x.SetDisplayName("QuartzJob");
                x.SetServiceName("QuartzRun");
            });
        }
    }
}
